//
//  BeverageDecorator.m
//  Charles
//
//  Created by Leo on 2017/6/13.
//  Copyright © 2017年 charles. All rights reserved.
//

#import "BeverageDecorator.h"

@implementation Soy {
    NSString *_name;
}

- (void)dealloc
{
    NSLog(@"%@ dealloc",NSStringFromClass(self.class));
}

- (instancetype)initWithBeverage:(id<Beverage>)beverage {
    if (self = [super init]) {
        _name = @"Soy";
        self.beverage = beverage;
    }
    return self;
}

- (NSString *)getName {
    return [NSString stringWithFormat:@"%@ + %@",[self.beverage getName],_name];
}

- (double)cost {
    return 0.3 + [self.beverage cost];
}

@end

@implementation Milk {
    NSString *_name;
}

- (void)dealloc
{
    NSLog(@"%@ dealloc",NSStringFromClass(self.class));
}

- (instancetype)initWithBeverage:(id<Beverage>)beverage {
    if (self = [super init]) {
        _name = @"Milk";
        self.beverage = beverage;
    }
    return self;
}

- (NSString *)getName {
    return [NSString stringWithFormat:@"%@ + %@",[self.beverage getName],_name];
}

- (double)cost {
    return 0.1 + [self.beverage cost];
}

@end

@implementation Mocha {
    NSString *_name;
}

- (void)dealloc
{
    NSLog(@"%@ dealloc",NSStringFromClass(self.class));
}

- (instancetype)initWithBeverage:(id<Beverage>)beverage {
    if (self = [super init]) {
        _name = @"Mocha";
        self.beverage = beverage;
    }
    return self;
}

- (NSString *)getName {
    return [NSString stringWithFormat:@"%@ + %@",[self.beverage getName],_name];
}

- (double)cost {
    return 1.1 + [self.beverage cost];
}

@end

@implementation Whip {
    NSString *_name;
}

- (void)dealloc
{
    NSLog(@"%@ dealloc",NSStringFromClass(self.class));
}

- (instancetype)initWithBeverage:(id<Beverage>)beverage {
    if (self = [super init]) {
        _name = @"Whip";
        self.beverage = beverage;
    }
    return self;
}

- (NSString *)getName {
    return [NSString stringWithFormat:@"%@ + %@",[self.beverage getName],_name];
}

- (double)cost {
    return 0.33 + [self.beverage cost];
}

@end
